/***********************************************************************
 * Module:  Npc.java
 * Author:  luohaoyang
 * Purpose: Defines the Class NPC
 ***********************************************************************/

package com.afteryuan.engine.model;
                
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

import com.afteryuan.dao.BaseObject;

@Entity 
@Table(name = "T_COMPONENT")
public class Component extends BaseObject {

	public static Integer COMPRESS_PNG = 0;
    public static Integer COMPRESS_SWF = 1;

	public static final Integer TYPE_DEFAULT=0; 
    public static final Integer TYPE_BUILDING=1;
    public static final Integer TYPE_PLANT=2;
    public static final Integer TYPE_LANDFORMS=3;
    public static final Integer TYPE_FURNITURE=4;
    public static final Integer TYPE_DECORATION=5;
    public static final Integer TYPE_INSTALLATION=6;
    public static final Integer TYPE_LINK=7;
    public static final Integer TYPE_BUTTON=8;
    public static final Integer TYPE_CARRIERS=9;
    
    public static final Integer FUNC_DEFAULT=0; 
    public static final Integer FUNC_TRANSPORT=1;
    public static final Integer FUNC_SEAT=2; 
    public static final Integer FUNC_INPLAYER=3; 
    public static final Integer FUNC_POPPLAYER=4; 
    public static final Integer FUNC_HOUSEDESK=5;
    public static final Integer FUNC_SANDTABLE=6; 
    public static final Integer FUNC_EBOOK=7; 
    public static final Integer FUNC_POP=8;
    public static final Integer FUNC_SCENE360=9;
    public static final Integer FUNC_GAME=10;
    public static final Integer FUNC_KTV=11;
    public static final Integer FUNC_NPC=12; 
    public static final Integer FUNC_MIC=13;
    public static final Integer FUNC_BIRTHPOINT=14;
    public static final Integer FUNC_REFRESHPOINT=15;
    public static final Integer FUNC_SITPOINT=16; 
    
    private String id;//ID
    private String name;//名称
    private Integer type;//实体类型
    private Integer func;//功能分类
    private String xmlData;//属性内容
    private Integer status;//状态
    private Long createTime;
    private Long updateTime;
    private File resource;//组件相关文件
    private Integer x;
    private Integer y;
    private Integer isSwap;//是否swap组件1,0
    private Integer topX;//block区域最顶端的点在图片的X坐标
    private Integer topY;//block区域最顶端的点在图片的Y坐标
    private Integer width;//BLOCK区域在斜坐标系下X方向的菱形格数量
    private Integer height;//BLOCK区域在斜坐标系下Y方向的菱形格数量    
    private Integer compress;
	public Component(String id) {
        this.id = id;
        setCreateTime(new Date().getTime());
    }
    public Component() {
        setCreateTime(new Date().getTime());
    }

    @Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
    @Column(name="F_COMPRESS")
    public Integer getCompress() {
        return compress;
    }

	public void setCompress(Integer compress) {
        this.compress = compress;
    }
    
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
    @Column(updatable = false)
    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    @ManyToOne
    @JoinColumn(name = "resource_id")
    public File getResource() {
        return resource;
    }

    public void setResource(File resource) {
        this.resource = resource;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Component that = (Component) o;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;

        return true;
    }

    public int hashCode() {
        return (id != null ? id.hashCode() : 0);
    }


    public String toString() {
        return "As3Component{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", type=" + type +
                ", func=" + func +
                ", status=" + status +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
	public Integer getFunc() {
		return func;
	}
	public void setFunc(Integer func) {
		this.func = func;
	}
	public String getXmlData() {
		return xmlData;
	}
	public void setXmlData(String xmlData) {
		this.xmlData = xmlData;
	}
	public Integer getTopX() {
		return topX;
	}
	public void setTopX(Integer topX) {
		this.topX = topX;
	}
	public Integer getTopY() {
		return topY;
	}
	public void setTopY(Integer topY) {
		this.topY = topY;
	}
	public Integer getWidth() {
		return width;
	}
	public void setWidth(Integer width) {
		this.width = width;
	}
	public Integer getHeight() {
		return height;
	}
	public void setHeight(Integer height) {
		this.height = height;
	}
	public Integer getX() {
		return x;
	}
	public void setX(Integer x) {
		this.x = x;
	}
	public Integer getY() {
		return y;
	}
	public void setY(Integer y) {
		this.y = y;
	}
	public Integer getIsSwap() {
		return isSwap;
	}
	public void setIsSwap(Integer isSwap) {
		this.isSwap = isSwap;
	}

}